var model = require('../models'),
    MUser = model.MUser,
    PayOff = model.PayOff;
var crypto = require('crypto');

function initUser() {
    var user = new MUser();
    user.user_name = "admin";
    var md5 = crypto.createHash('md5');
    md5.update('123456')
    user.user_passwd = md5.digest('hex');
    user.saveMUser(function (err) {
        if (err) {
            console.log(err);
        } else {
            console.log('user is save!');
        }
    })
}
initUser();

function initPayoff(count) {
    console.log('ssssssssssssssssssssssssssss');
    var payoff = new PayOff();
    payoff.payoff_count = count;
    payoff.income = count * 10;
    payoff.payoff_totalcount = 1000;
    payoff.payoff_date = new Date();
    payoff.pay = 0;
    payoff.wcopenid = 'oqaCmjjQ26Zlcgmk_BnhJwoELXSg';
    payoff.savePayoff(function (err) {
        if (err) {
            console.log(err);
        } else {
            console.log('payoff is save');
        }
    })
}

for (var i = 0; i < 3; i++) {
    initPayoff(i);
}


var md5 = crypto.createHash('md5');
md5.update('123456')

console.log(md5.digest('hex'));